import subprocess


def main(remote_ip,zip_path,remote_dir,logger):
    command = f'/data/Yang/environment/project_1/bin/python /data/Yang/project_1/SentinelL1cRasterServer.py {zip_path} {remote_dir}'     # 需要执行的cmd命令
    ssh_command = f'ssh root@{remote_ip} "{command}"'
    process = subprocess.run(
        ssh_command, 
        shell=True, 
        stdout=subprocess.PIPE, 
        stderr=subprocess.PIPE, 
        text=True)
    if error:
        logger.info("Error:", process.stderr)
        return False
    else:
        logger.info("Output:", process.stdout)
        return True


def core(remote_ip,remote_dir,zipfile_queue,messge_queue,logger):
    while True:
        element = zipfile_queue.get()
        if element is None: break
        zip_path = element
        status = main(remote_ip,zip_path,remote_dir,logger)
        if status:
            messge_queue.put(zip_path)
        else:
            zipfile_queue.put(zip_path)
    messge_queue.put(zip_path)     
    return